﻿Imports SIGI.Common.BE

Public Class UC_Image
#Region "<< -Attibutes- >>"
    Private _ImgPath As String = String.Empty
    Private _Id As Integer = 0
#End Region

#Region "<< -Properties- >>"
    Public ReadOnly Property ImageLocation
        Get
            Return _ImgPath
        End Get
    End Property

    Public ReadOnly Property Id
        Get
            Return _Id
        End Get
    End Property
#End Region

#Region "<< -Events - >>"
    Private Sub btnSearch_Click(sender As System.Object, e As System.EventArgs) Handles btnSearch.Click
        Dim wFrm As frmVisor = New frmVisor With {.ImagePath = _ImgPath}
        wFrm.ShowDialog()
    End Sub

    Private Sub frm_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress
        If Convert.ToInt32(e.KeyChar) = Keys.Escape Then
            'Cierro el formulario
            DirectCast(sender, Form).Close()
        End If
    End Sub
#End Region

#Region "<< -Methods- >>"
    Public Sub New(pImgPath As String)
        InitializeComponent()

        _ImgPath = pImgPath
        picImg.ImageLocation = pImgPath
    End Sub

    Public Sub New(pImage As ImagesPerPropertyBE)
        InitializeComponent()

        _ImgPath = pImage.Description
        _Id = pImage.Id
        picImg.ImageLocation = pImage.Description
    End Sub

    Public Sub SetImage(pImgPath As String)
        _ImgPath = pImgPath
        picImg.ImageLocation = pImgPath
        chkSelect.Checked = False
    End Sub

    Public Sub CleanImage()
        _ImgPath = String.Empty
        picImg.ImageLocation = String.Empty
        chkSelect.Checked = False
    End Sub

    Public Function Selected() As Boolean
        Return chkSelect.Checked
    End Function
#End Region


End Class
